<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline" @keyup.enter.native="search()">
      <el-form-item label="  会员名称/手机">
        <br />
        <br />
        <el-input v-model="formInline.keyword" clearable style="margin-left: -90px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  领奖人手机/名称">
        <br />
        <br />
        <el-input v-model="formInline.keyWords" clearable style="margin-left: -100px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  活动名称">
        <br />
        <br />
        <el-input v-model="formInline.activityName" clearable style="margin-left: -60px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  店铺编码">
        <br />
        <br />
        <el-input v-model="formInline.authCode" clearable style="margin-left: -60px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  门店名称">
        <br />
        <br />
        <el-input v-model="formInline.storeName" clearable style="margin-left: -60px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  所属省">
        <br />
        <br />
        <el-input v-model="formInline.province" clearable style="margin-left: -50px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  所属城市">
        <br />
        <br />
        <el-input v-model="formInline.city" clearable style="margin-left: -60px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  所属区县">
        <br />
        <br />
        <el-input v-model="formInline.county" clearable style="margin-left: -60px; width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="  所属大区" v-show="userType && userType2">
        <br />
        <br />
        <el-select v-model="formInline.zqOrgSeq" placeholder="所属大区" clearable filterable
          @change="selCore(formInline.zqOrgSeq)" style="width: 200px; margin-left: -60px">
          <el-option v-for="item in corpList" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  所属营销区域" v-show="userType">
        <br />
        <br />
        <el-select v-model="formInline.baseOrgSeq" clearable filterable @change="selbase(formInline.baseOrgSeq)"
          style="width: 200px; margin-left: -60px">
          <el-option v-for="item in RentalPayWay" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  赠品类型">
        <br />
        <br />
        <el-select style="margin-left: -60px; width: 200px" v-model="formInline.giftType" clearable>
          <el-option label="虚拟赠品" value="2"></el-option>
          <el-option label="实物赠品" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  发货状态">
        <br />
        <br />
        <el-select style="margin-left: -60px; width: 200px" v-model="formInline.isDeliver" clearable>
          <el-option label="已发货" value="1"></el-option>
          <el-option label="未发货" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  会员等级">
        <br />
        <br />
        <el-select style="margin-left: -60px; width: 200px" v-model="formInline.gradelevelId" clearable>
          <el-option v-for="(send, i) in options" :key="i" :value="send.uuid" :label="send.gradelevelName"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  赠品等级">
        <br />
        <br />
        <el-select v-model="formInline.prizeLevelId" filterable clearable @blur="selectBlur"
          style="margin-left: -60px; width: 200px">
          <el-option v-for="(send, i) in leveloptions" :key="i" :value="send.prizeLevelName"
            :label="send.prizeLevelName"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  配送方式">
        <br />
        <br />
        <el-select style="margin-left: -60px; width: 200px" v-model="formInline.deliveryType"
          @change="changeDeliveryType(formInline.deliveryType)" clearable>
          <el-option label="专卖店配送" value="1"></el-option>
          <el-option label="五粮液总部配送" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  奖品配送方式" v-show="false">
        <br />
        <br />
        <el-select style="margin-left: -60px; width: 200px" v-model="formInline.memberPstype"
          :disabled="formInline.deliveryType == 2" clearable>
          <el-option v-show="formInline.deliveryType != 2" label="自提" value="2"></el-option>
          <el-option v-show="formInline.deliveryType != 2" label="商家配送" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  配送状态" v-show="showsx">
        <br />
        <br />
        <el-select style="margin-left: -60px; width: 200px" v-model="formInline.isReceive" clearable>
          <el-option label="待确认" value="0"></el-option>
          <el-option v-if="formInline.deliveryType != 2" label="待配送(待领取)" value="1"></el-option>
          <el-option v-if="formInline.deliveryType == 2" label="已确认" value="1"></el-option>
          <el-option v-if="formInline.deliveryType != 2" label="已配送(已领取)" value="3"></el-option>
          <el-option label="已过期" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="  中奖日期" v-show="showsx">
        <br />
        <br />
        <el-date-picker v-model="formInline.dateRange" type="daterange" align="right" unlink-panels range-separator="至"
          start-placeholder="中奖开始日期" end-placeholder="中奖结束日期" value-format="yyyy-MM-dd" :picker-options="pickerOptions"
          style="margin-left: -60px; width: 290px"></el-date-picker>
      </el-form-item>
      <el-form-item label="  发货日期" v-show="showsx">
        <br />
        <br />
        <el-date-picker style="margin-left: -60px; width: 290px" v-model="formInline.dateRangefh" type="daterange"
          align="right" unlink-panels range-separator="至" start-placeholder="发货开始日期" end-placeholder="发货结束日期"
          value-format="yyyy-MM-dd" :picker-options="pickerOptionsfh"></el-date-picker>
      </el-form-item>
      <el-form-item label="  配送日期" v-show="showsx">
        <br />
        <br />
        <el-date-picker v-model="formInline.dateRangeps" type="daterange" align="right" unlink-panels
          range-separator="至" start-placeholder="配送开始日期" end-placeholder="配送结束日期" value-format="yyyy-MM-dd"
          :picker-options="pickerOptionsps" style="margin-left: -60px; width: 290px"></el-date-picker>
      </el-form-item>
      <!-- <el-form-item label>
                <el-date-picker
                    v-model="formInline.dateRangeGet"
                    type="daterange"
                    align="right"
                    unlink-panels
                    range-separator="至"
                    start-placeholder="领取开始日期"
                    end-placeholder="领取结束日期"
                    value-format="yyyy-MM-dd"
                    :picker-options="pickerOptionsps"
                ></el-date-picker>
            </el-form-item> -->
      <div style="width: 100%; display: flex; justify-content: flex-end">
        <el-form-item>
          <el-button type="primary" @click="shaixuan()" size="mini">{{
            shaixuanval
          }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="search()" size="mini" icon="el-icon-search">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="kong()" size="mini" icon="el-icon-delete">清空</el-button>
        </el-form-item>
        <!-- <el-form-item>
                <el-button size="mini" type="success">
                    <a
                        style="color: #ffffff;"
                        class="download"
                        :href="this.hrefUrl"
                        download
                        title="下载"
                    >下载</a>
                </el-button>
            </el-form-item>-->
        <el-form-item>
          <el-button type="primary" @click="selectSend2()" size="mini"
            :disabled="this.dataListSelections.length == 0">批量发货</el-button>
          <el-button @click="exportExcel1" style="margin-top: 0px" size="mini" type="success" icon="el-icon-s-data"
            :loading="exportLoading">导出</el-button>
          <!-- <a
                    :href="getExcel(this.formInline.keyword,this.formInline.keywords,this.formInline.isReceive,
                 this.formInline.giftType,this.formInline.isDeliver,this.formInline.gradelevelId,this.formInline.prizeLevelId,
                 this.formInline.dateRange[0],this.formInline.dateRange[1])"
                    download
                >导出到Excel</a>-->
          <el-button type="primary" @click="showConfigTableDialog()" size="mini" icon="el-icon-setting"
            :loading="insertLoading">列表配置</el-button>
        </el-form-item>
      </div>
    </el-form>
    <el-table @selection-change="selectionChangeHandle" :data="tableData" style="margin-bottom: 20px; height: 500px"
      height="400px" :header-cell-style="{ background: '#eef1f6', color: '#606266' }" border v-loading="loading">
      <el-table-column type="selection" :selectable="checkboxT" width="55" align="center"
        fixed="left"></el-table-column>
      <el-table-column type="index" label="序号" align="center" width="60"></el-table-column>
      <el-table-column prop="activityName" label="活动名称" width="180" align="center" show-overflow-tooltip
        v-if="isShow('activityName')"></el-table-column>
      <el-table-column prop="memberName" label="会员名称" width="160" align="left" show-overflow-tooltip
        v-if="isShow('memberName')"></el-table-column>
      <el-table-column prop="memberLevelName" label="会员等级" width="160" align="center" show-overflow-tooltip
        v-if="isShow('memberLevelName')"></el-table-column>
      <el-table-column prop="memberPhone" label="手机号码" width="160" align="center" show-overflow-tooltip
        v-if="isShow('memberPhone')"></el-table-column>

      <el-table-column prop="prizeLevelName" label="赠品等级" width align="center" show-overflow-tooltip
        v-if="isShow('prizeLevelName')"></el-table-column>
      <el-table-column prop="giftName" label="赠品名称" width="180" align="left" show-overflow-tooltip
        v-if="isShow('prizeName')"></el-table-column>
      <el-table-column prop="giftType" label="赠品类型" width="180" align="center" show-overflow-tooltip
        v-if="isShow('giftType')">
        <template slot-scope="scope">
          <span v-if="scope.row.giftType != null">{{
            scope.row.giftType === 2 ? '虚拟赠品' : '实物赠品'
          }}</span>
          <span v-if="scope.row.giftType == null">-</span>
        </template>
      </el-table-column>
      <el-table-column prop="winningTime" label="中奖时间" width="180" align="left" show-overflow-tooltip
        v-if="isShow('winningTime')"></el-table-column>
      <el-table-column prop="deliverTime" label="发货时间" width="180" align="left" show-overflow-tooltip
        v-if="isShow('deliverTime')"></el-table-column>
      <el-table-column prop="receiveTime" label="配送时间" width="180" align="left" show-overflow-tooltip
        v-if="isShow('receiveTime')"></el-table-column>

      <el-table-column prop="deliveryType" label="配送方式" width="180" align="center" show-overflow-tooltip
        v-if="isShow('deliveryType')">
        <template slot-scope="scope">
          <span v-if="scope.row.giftType != 2 && scope.row.deliveryType != null">{{
            scope.row.deliveryType === 1 ? '专卖店配送' : '五粮液总部配送'
          }}</span>
          <span v-if="scope.row.deliveryType == null">-</span>
          <span v-if="scope.row.giftType == 2">-</span>
        </template>
      </el-table-column>
      <el-table-column prop="authCode" label="店铺编码" width="180" align="left" show-overflow-tooltip
        v-if="isShow('authCode')"></el-table-column>
      <el-table-column prop="storeName" label="所属专卖店" width="180" align="left" show-overflow-tooltip
        v-if="isShow('storeName')"></el-table-column>
      <el-table-column prop="province" label="店铺所属省" width="180" align="left" show-overflow-tooltip
        v-if="isShow('province')"></el-table-column>
      <el-table-column prop="city" label="店铺所属市" width="180" align="left" show-overflow-tooltip
        v-if="isShow('city')"></el-table-column>
      <el-table-column prop="county" label="店铺所属区" width="180" align="left" show-overflow-tooltip
        v-if="isShow('county')"></el-table-column>

      <el-table-column prop="zqName" label="大区名称" width="180" align="left" show-overflow-tooltip
        v-if="isShow('zqName')"></el-table-column>
      <el-table-column prop="baseName" label="营销区域名称" width="180" align="left" show-overflow-tooltip
        v-if="isShow('baseName')"></el-table-column>

      <el-table-column prop="name" label="领奖人姓名" width="180" align="center" show-overflow-tooltip v-if="isShow('name')">
        <template slot-scope="scope">
          <span v-if="scope.row.name != null">{{ scope.row.name }}</span>
          <span v-if="scope.row.name == null">-</span>
        </template>
      </el-table-column>
      <el-table-column prop="tel" label="领奖人手机号码" width="180" align="center" show-overflow-tooltip v-if="isShow('tel')">
        <template slot-scope="scope">
          <span v-if="scope.row.tel != null">{{ scope.row.tel }}</span>
          <span v-if="scope.row.tel == null">-</span>
        </template>
      </el-table-column>
      <el-table-column prop="address" label="领奖人收货地址" width="260" align="center" show-overflow-tooltip
        v-if="isShow('address')">
        <template slot-scope="scope">
          <span v-if="scope.row.address != null || scope.row.position != null">{{ scope.row.position + ' ' +
            scope.row.address }}</span>
          <span v-if="scope.row.address == null && scope.row.position == null">-</span>
        </template>
      </el-table-column>

      <el-table-column prop="memberInfo" label="用户信息" width="180" align="left" show-overflow-tooltip
        v-if="isShow('memberInfo')"></el-table-column>
      <el-table-column prop="memberPstype" label="奖品配送方式" width="180" align="center" show-overflow-tooltip v-if="false">
        <template slot-scope="scope">
          <span v-if="scope.row.giftType != 2 && scope.row.memberPstype != null">{{ scope.row.memberPstype === 2 ? '自提'
            : '商家配送' }}</span>
          <span v-if="scope.row.memberPstype == null">-</span>
          <span v-if="scope.row.giftType == 2">-</span>
        </template>
      </el-table-column>
      <el-table-column prop="isReceive" label="配送状态" width="180" align="center" show-overflow-tooltip
        v-if="isShow('isReceive')">
        <template slot-scope="scope">
          <span v-if="
            scope.row.giftType != 2 &&
            scope.row.isReceive != null &&
            scope.row.isReceive == 0
          ">{{ '待确认' }}</span>
          <span v-if="
            scope.row.giftType != 2 &&
            scope.row.isReceive != null &&
            scope.row.memberPstype != 2 &&
            scope.row.deliveryType != 2 &&
            scope.row.isReceive == 1
          ">{{ '待配送' }}</span>
          <span v-if="
            scope.row.giftType != 2 &&
            scope.row.isReceive != null &&
            scope.row.memberPstype != 2 &&
            scope.row.deliveryType == 2 &&
            scope.row.isReceive == 1
          ">{{ '已确认' }}</span>
          <span v-if="
            scope.row.giftType != 2 &&
            scope.row.isReceive != null &&
            scope.row.memberPstype != 2 &&
            scope.row.isReceive == 3
          ">{{ '已配送' }}</span>
          <span v-if="
            scope.row.giftType != 2 &&
            scope.row.isReceive != null &&
            scope.row.memberPstype == 2 &&
            scope.row.isReceive == 1
          ">{{ '待领取' }}</span>
          <span v-if="
            scope.row.giftType != 2 &&
            scope.row.isReceive != null &&
            scope.row.memberPstype == 2 &&
            scope.row.isReceive == 3
          ">{{ '已领取' }}</span>
          <span v-if="
            scope.row.giftType != 2 &&
            scope.row.isReceive != null &&
            scope.row.isReceive == 2
          ">{{ '已过期' }}</span>
          <span v-if="scope.row.isReceive == null">-</span>
          <span v-if="scope.row.giftType == 2">-</span>
        </template>
      </el-table-column>
      <el-table-column prop="isDeliver" label="发货状态" width="180" align="center" show-overflow-tooltip
        v-if="isShow('isDeliver')">
        <template slot-scope="scope">
          <span v-if="scope.row.giftType != 2 && scope.row.isDeliver != null">{{
            scope.row.isDeliver === 1 ? '已发货' : '未发货'
          }}</span>
          <span v-if="scope.row.isDeliver == null">-</span>
          <span v-if="scope.row.giftType == 2">-</span>
        </template>
      </el-table-column>
      <el-table-column prop="getTime" label="领取时间" width="180" align="left" show-overflow-tooltip
        v-if="false"></el-table-column>

      <!-- <el-table-column label="操作" width="280" align="center">
                <template slot-scope="scope">
                    <el-button type="text" size="mini" @click="editInfo(scope.row)">修改</el-button>
                    <el-button type="text" size="mini" @click="handledelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>-->
    </el-table>
    <el-form :inline="true" :model="formInline">
      <el-form-item style="margin-top: 6px"></el-form-item>
    </el-form>
    <div class="block" style="margin-top: -49px">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30, 50, 100, 150, 200]" :current-page="listQuery.current" :page-size="listQuery.size"
        layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
    </div>

    <!--列表配置-->
    <el-dialog title="列表配置" :visible.sync="configTableDialogVisible" width="50%" @close="closeConfigTableDialog()">
      <div id="configTableDiv">
        <el-form :inline="true" :model="formInline2" class="demo-form-inline">
          <el-form-item label="选择列表字段：">
            <el-checkbox :indeterminate="formInline2.isIndeterminate" v-model="formInline2.isAll"
              style="margin-top: 10px" @change="isAllFieldChange">全选</el-checkbox>
          </el-form-item>
          <el-divider></el-divider>
          <el-checkbox-group v-model="userMenuShowFields" @change="isSingleFieldChange">
            <el-checkbox v-for="item in userMenuFieldList" :label="item.fieldCode" :key="item.fieldCode"
              style="margin: 15px 10px; width: 120px">{{ item.fieldName }}</el-checkbox>
          </el-checkbox-group>
        </el-form>
        <el-row>
          <el-col :span="24" style="text-align: center; margin-top: 30px">
            <el-button type="info" @click="closeConfigTableDialog()" size="mini">返 回</el-button>
            <el-button type="primary" @click="insertUserFieldRelation()" size="mini">确 认</el-button>
          </el-col>
        </el-row>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getAllZone, getAllBase, getAllShop } from '@/api/addShopapply.js';
import { getmemberrule } from '@/api/membergrade';
import {
  queryWinningRecordList,
  batchDeliverGoods,
  queryWinningRecordListExcel,
} from '@/api/winningCheck';
import imageUpload from '@/page/common/Image-upload';
import qs from 'qs';
import FileSaver from 'file-saver';
import XLSX from 'xlsx';
import {
  queryUserMenuFieldByParam,
  insertUserFieldRelation,
} from '@/api/tradeOrderSearch';
export default {
  data() {
    return {
      shaixuanval: '筛选条件展开',
      showsx: false,
      hrefUrl:
        'http:127.0.0.1:18080/api/promotion-service/v1/winningRecord/queryWinningRecordListExcel',
      leveloptions: [
        { prizeLevel: '0', prizeLevelName: '特等奖' },
        { prizeLevel: '1', prizeLevelName: '一等奖' },
        { prizeLevel: '2', prizeLevelName: '二等奖' },
        { prizeLevel: '3', prizeLevelName: '三等奖' },
        { prizeLevel: '4', prizeLevelName: '四等奖' },
        { prizeLevel: '5', prizeLevelName: '五等奖' },
        { prizeLevel: '6', prizeLevelName: '六等奖' },
        { prizeLevel: '7', prizeLevelName: '七等奖' },
        { prizeLevel: '8', prizeLevelName: '八等奖' },
        { prizeLevel: '9', prizeLevelName: '九等奖' },
      ],
      options: [],
      userType: false,
      userType2: false,
      orgSeq: '',
      corpList: [], //大区列表
      RentalPayWay: [], //营销区域列表
      tableData: [],
      tableDataExcel: [],
      shopLevelList: [],
      dataListSelections: [],
      lsGoodsList: [],
      loading: true,
      exportLoading: false,
      insertLoading: false,
      total: 0,
      listQuery: {
        current: 1,
        size: 100,
      },
      total2: 0,
      listQuery2: {
        current: 1,
        size: 100,
      },
      dialogVisible: false,
      dialogVisibleLevel: false,
      formInline: {
        userType: '',
        keyword: '',
        keyWords: '',
        activityName: '',
        authCode: '',
        storeName: '',
        province: '',
        city: '',
        county: '',
        zqOrgSeq: '',
        baseOrgSeq: '',
        status: '',
        giftType: '',
        memberPstype: '',
        isReceive: '',
        deliveryType: '',
        isDeliver: '',
        gradelevelId: '',
        prizeLevelId: '',
        dateRange: [],
        dateRangefh: [],
        dateRangeps: [],
        dateRangeGet: [],
        orgSeq: '',
        orgType: 1,
      },
      rules: {},
      configTableDialogVisible: false, //列表配置弹窗状态
      formInline2: {
        isIndeterminate: false, //是否半选中
        isAll: true, //是否全部显示,
        menuCode: 'winningCheck',
      },
      userMenuFieldList: [], //全部列名列表
      userMenuAllFields: [], //全部的列名
      userMenuShowFields: [], //显示的列名
      pickerOptions: {
        shortcuts: [
          {
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            },
          },
        ],
      },
      pickerOptionsfh: {
        shortcuts: [
          {
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            },
          },
        ],
      },
      pickerOptionsps: {
        shortcuts: [
          {
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            },
          },
        ],
      },
    };
  },
  mounted() {
    this.logininfo = localStorage.getItem('logininfo');
    this.orgList = JSON.parse(this.logininfo).orgList;
    if (this.orgList[0].orgType == 4) {
      this.formInline.orgSeq = this.orgList[0].orgSeq;
    }

    this.orgSeq = this.orgList[0].orgSeq;
    this.formInline.userType = JSON.parse(this.logininfo).userType;
    this.userType =
      this.formInline.userType !== '4' && this.formInline.userType !== '5';
    this.userType2 = this.formInline.userType == '2' ? false : true;
    if (this.userType2 == false) {
      this.selCore(this.orgSeq);
      this.formInline.zqOrgSeq = this.orgSeq;
    }

    this._getAllZone();

    this.queryUserMenuFieldByParam();
    this.getDataList();
    this._getmemberinfo();
  },
  components: {
    imageUpload,
  },
  created() { },
  methods: {
    // 筛选条件展开
    shaixuan() {
      if (this.showsx == false) {
        this.shaixuanval = '筛选条件关闭';
        this.showsx = true;
      } else {
        this.shaixuanval = '筛选条件展开';
        this.showsx = false;
      }
    },
    //导出
    getExcel(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10) {
      return (
        `http:127.0.0.1:18080/api/promotion-service/v1/winningRecord/queryWinningRecordListExcel?keyword=` +
        k1 +
        `&current=` +
        1 +
        `&size=` +
        999 +
        `&keyWords=` +
        k2 +
        '&memberLevel=' +
        k3 +
        '&prizeLevelName=' +
        k4 +
        '&status=' +
        k5 +
        '&isReceive=' +
        k6 +
        '&isDeliver=' +
        k7 +
        '&giftType=' +
        k8 +
        '&beginDate=' +
        k9 +
        '&endDate=' +
        k10
      );
    },

    checkboxT(row, index) {
      if (row.deliveryType == 1) {
        // 已领取或者已配送才能够进行勾选
        return (row.giftType != 2 &&
          row.isReceive != null &&
          row.memberPstype == 2 &&
          row.isReceive == 3) ||
          (row.giftType != 2 &&
            row.isReceive != null &&
            row.memberPstype != 2 &&
            row.isReceive == 3)
        // 五粮液总部配送
      } else if (row.deliveryType == 2) {
        // 已确认/已配送才进行勾选
        return (row.giftType != 2 &&
          row.isReceive != null &&
          row.memberPstype != 2 &&
          row.deliveryType == 2 &&
          row.isReceive == 1) ||
          (row.giftType != 2 &&
          row.isReceive != null &&
          row.memberPstype != 2 &&
          row.isReceive == 3)
      } else {
        return false;
      }
      // if (row.isDeliver == 1 || row.giftType == 2) {
      //   return false; //不可勾选  已经配送
      // }
      // // else if (row.deliveryType == 2) {
      // //   return false; //不可勾选 专卖店配送
      // // }
      // else {
      //   return true; //可勾选
      // }
    },
    kong() {
      this.formInline.keyword = '';
      this.formInline.keyWords = '';
      this.formInline.activityName = '';
      this.formInline.authCode = '';
      this.formInline.storeName = '';
      this.formInline.province = '';
      this.formInline.city = '';
      this.formInline.county = '';
      if (this.userType2) {
        this.formInline.zqOrgSeq = '';
      }
      this.formInline.baseOrgSeq = '';
      this.formInline.gradelevelId = '';
      this.formInline.prizeLevelId = '';
      this.formInline.status = '';
      this.formInline.memberPstype = '';
      this.formInline.isReceive = '';
      this.formInline.deliveryType = '';
      this.formInline.isDeliver = '';
      this.formInline.giftType = '';
      this.formInline.dateRange = [];
      this.formInline.dateRangefh = [];
      this.formInline.dateRangeps = [];
      this.formInline.dateRangeGet = [];
    },
    search() {
      this.loading = true;
      this.listQuery.current = 1;
      let data = {
        size: this.listQuery.size,
        current: this.listQuery.current,
        condition: {
          keyword: this.formInline.keyword.trim(),
          keyWords: this.formInline.keyWords.trim(),
          activityName: this.formInline.activityName.trim(),
          authCode: this.formInline.authCode.trim(),
          storeName: this.formInline.storeName.trim(),
          province: this.formInline.province.trim(),
          city: this.formInline.city.trim(),
          county: this.formInline.county.trim(),
          zqOrgSeq: this.formInline.zqOrgSeq,
          baseOrgSeq: this.formInline.baseOrgSeq,
          memberLevel: this.formInline.gradelevelId,
          prizeLevelName: this.formInline.prizeLevelId,
          status: this.formInline.status,
          memberPstype: this.formInline.memberPstype,
          isReceive: this.formInline.isReceive,
          deliveryType: this.formInline.deliveryType,
          isDeliver: this.formInline.isDeliver,
          giftType: this.formInline.giftType,
          beginDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 0
              ? this.formInline.dateRange[0]
              : '',
          endDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 1
              ? this.formInline.dateRange[1]
              : '',
          fhBeginDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 0
              ? this.formInline.dateRangefh[0]
              : '',
          fhEndDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 1
              ? this.formInline.dateRangefh[1]
              : '',
          psBeginDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 0
              ? this.formInline.dateRangeps[0]
              : '',
          psEndDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 1
              ? this.formInline.dateRangeps[1]
              : '',
          orgSeq: this.formInline.orgSeq,
          getBeginDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 0
              ? this.formInline.dateRangeGet[0]
              : '',
          getEndDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 1
              ? this.formInline.dateRangeGet[1]
              : '',
        },
      };

      if (this.$route.params.activityType == 3 || this.$route.params.activityType == 4) {
        data.condition.activityId = this.$route.params.activityId
      }

      queryWinningRecordList(data).then((res) => {
        this.loading = false;
        this.total = res.total;
        this.tableData = res.records;
      });
    },
    handleSizeChange(val) {
      this.listQuery.size = val;
      this.getDataList();
    },
    handleCurrentChange(val) {
      this.listQuery.current = val;
      this.getDataList();
    },

    getDataList() {
      let data = {
        size: this.listQuery.size,
        current: this.listQuery.current,
        condition: {
          keyword: this.formInline.keyword.trim(),
          keyWords: this.formInline.keyWords.trim(),
          activityName: this.formInline.activityName.trim(),
          authCode: this.formInline.authCode.trim(),
          storeName: this.formInline.storeName.trim(),
          province: this.formInline.province.trim(),
          city: this.formInline.city.trim(),
          county: this.formInline.county.trim(),
          zqOrgSeq: this.formInline.zqOrgSeq,
          baseOrgSeq: this.formInline.baseOrgSeq,
          memberLevel: this.formInline.gradelevelId,
          prizeLevelName: this.formInline.prizeLevelId,
          status: this.formInline.status,
          memberPstype: this.formInline.memberPstype,
          isReceive: this.formInline.isReceive,
          deliveryType: this.formInline.deliveryType,
          isDeliver: this.formInline.isDeliver,
          giftType: this.formInline.giftType,
          beginDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 0
              ? this.formInline.dateRange[0]
              : '',
          endDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 1
              ? this.formInline.dateRange[1]
              : '',
          fhBeginDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 0
              ? this.formInline.dateRangefh[0]
              : '',
          fhEndDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 1
              ? this.formInline.dateRangefh[1]
              : '',
          psBeginDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 0
              ? this.formInline.dateRangeps[0]
              : '',
          psEndDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 1
              ? this.formInline.dateRangeps[1]
              : '',
          orgSeq: this.formInline.orgSeq,
          getBeginDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 0
              ? this.formInline.dateRangeGet[0]
              : '',
          getEndDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 1
              ? this.formInline.dateRangeGet[1]
              : '',
        },
      };
      if (this.$route.params.activityType == 3 || this.$route.params.activityType == 4) {
        data.condition.activityId = this.$route.params.activityId
      }
      queryWinningRecordList(data).then((res) => {
        this.loading = false;
        this.total = res.total;
        this.tableData = res.records;
      });
    },

    // 多选表1
    selectionChangeHandle(val) {
      this.dataListSelections = val;
    },

    _getmemberinfo() {
      let data = {
        size: 99,
        current: 1,
        condition: {},
        ascs: [],
        descs: [],
      };
      getmemberrule(data).then((res) => {
        this.options = res.records;
      });
    },

    selectSends() {
      this.dialogVisibleLevel = !this.dialogVisibleLevel;
      this.getShopLevelList();
    },
    getShopLevelList() {
      this.loading = true;
      let data = {
        size: this.listQuery2.size,
        current: this.listQuery2.current,
        condition: {
          isDeliver: 0,
        },
        ascs: [],
        descs: [],
      };
      queryWinningRecordList(data).then((res) => {
        this.shopLevelList = res.records;
        this.total2 = res.total;
      });
      this.loading = false;
    },

    goodsChecked(row) {
      this.lsGoodsList = row;
    },

    handleSizeChange2(val) {
      this.listQuery2.size = val;
      this.getShopLevelList();
    },
    handleCurrentChange2(val) {
      this.listQuery2.current = val;
      this.getShopLevelList();
    },
    selectConfirm() {
      // 保存已选择的
      let data = [];
      this.lsGoodsList.forEach((item, i) => {
        let obj = { uuid: item.uuid, isReceive: 0 };
        data.push(obj);
      });
      batchDeliverGoods(data).then((res) => {
        this.$message({
          showClose: true,
          message: res.message,
          type: res.code == 1 ? 'success' : 'error',
        });
        this.dialogVisibleLevel = !this.dialogVisibleLevel;
      });
    },
    selectSend2() {
      // 保存已选择的
      this.$confirm('确认批量发货所选赠品？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          let data = [];
          this.dataListSelections.forEach((item, i) => {
            let obj = { uuid: item.uuid, isReceive: 0 };
            data.push(obj);
          });
          batchDeliverGoods(data).then((res) => {
            this.$message({
              showClose: true,
              message: res.code == 1 ? '操作成功' : '操作失败',
              type: res.code == 1 ? 'success' : 'error',
            });
            this.getDataList();
          });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消',
          });
        });
    },
    selectBlur(e) {
      this.formInline.prizeLevelId = e.target.value;
    },
    getDataListExcel() {
      let data = {
        size: this.total,
        current: 1,
        condition: {
          keyword: this.formInline.keyword.trim(),
          keyWords: this.formInline.keyWords.trim(),
          activityName: this.formInline.activityName.trim(),
          authCode: this.formInline.authCode.trim(),
          storeName: this.formInline.storeName.trim(),
          province: this.formInline.province.trim(),
          city: this.formInline.city.trim(),
          county: this.formInline.county.trim(),
          zqOrgSeq: this.formInline.zqOrgSeq,
          baseOrgSeq: this.formInline.baseOrgSeq,
          memberLevel: this.formInline.gradelevelId,
          prizeLevelName: this.formInline.prizeLevelId,
          status: this.formInline.status,
          memberPstype: this.formInline.memberPstype,
          isReceive: this.formInline.isReceive,
          deliveryType: this.formInline.deliveryType,
          isDeliver: this.formInline.isDeliver,
          giftType: this.formInline.giftType,
          beginDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 0
              ? this.formInline.dateRange[0]
              : '',
          endDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 1
              ? this.formInline.dateRange[1]
              : '',
          fhBeginDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 0
              ? this.formInline.dateRangefh[0]
              : '',
          fhEndDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 1
              ? this.formInline.dateRangefh[1]
              : '',
          psBeginDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 0
              ? this.formInline.dateRangeps[0]
              : '',
          psEndDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 1
              ? this.formInline.dateRangeps[1]
              : '',
          orgSeq: this.formInline.orgSeq,
          getBeginDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 0
              ? this.formInline.dateRangeGet[0]
              : '',
          getEndDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 1
              ? this.formInline.dateRangeGet[1]
              : '',
        },
      };
      queryWinningRecordList(data).then((res) => {
        if (res.code == 1) {
          this.tableDataExcel = res.records;
          if (this.tableDataExcel.length > 0) {
            this.exportExcel();
          } else {
            this.$message.error('数据为空无法导出!');
          }
        }
        setTimeout(() => {
          this.exportLoading = false;
        }, 3000);
      });
    },
    exportToo() {
      this.exportLoading = true;
      this.getDataListExcel();
    },
    exportExcel() {
      var that = this;
      //要导出去的标题
      var arry = [
        [
          '序号',
          '会员名称',
          '会员等级',
          '手机号码',
          '活动名称',
          '赠品等级',
          '赠品名称',
          '赠品类型',
          '中奖时间',
          '发货时间',
          '配送时间',
          '所属专卖店(授权编码)',
          '专卖店地址',
          '领奖人姓名',
          '领奖人手机号码',
          '领奖人收货地址',
          '配送状态',
          '配送方式',
          '发货状态',
          '大区名称',
          '营销区域名称',
        ],
      ];
      // that.Data指要导出的数据
      that.tableDataExcel
        .map((a, i) => {
          var _arry = [];
          _arry.push((1 + i).toString());
          _arry.push(a.memberName == null ? '' : a.memberName.toString());
          _arry.push(
            a.memberLevelName == null ? '' : a.memberLevelName.toString()
          );
          _arry.push(a.memberPhone == null ? '' : a.memberPhone.toString());
          _arry.push(a.activityName == null ? '' : a.activityName.toString());
          _arry.push(
            a.prizeLevelName == null ? '' : a.prizeLevelName.toString()
          );
          _arry.push(a.prizeName == null ? '' : a.prizeName.toString());
          _arry.push(
            a.giftType == null ? '' : a.giftType == 2 ? '虚拟赠品' : '实物赠品'
          );
          _arry.push(a.winningTime == null ? '' : a.winningTime); //格式化日期没有就返回空
          _arry.push(a.deliverTime == null ? '' : a.deliverTime); //格式化日期没有就返回空
          _arry.push(a.receiveTime == null ? '' : a.receiveTime); //格式化日期没有就返回空
          _arry.push(
            a.storeName == null
              ? ''
              : a.authCode == null
                ? '【' + a.storeName.toString() + '()】'
                : '【' +
                a.storeName.toString() +
                '(' +
                a.authCode.toString() +
                ')】'
          );
          _arry.push(a.storeAddress == null ? '' : a.storeAddress.toString());
          _arry.push(a.name == null ? '' : a.name.toString());
          _arry.push(a.tel == null ? '' : a.tel.toString());
          _arry.push(a.address == null ? '' : a.position + ' ' + a.address);
          _arry.push(
            a.giftType == 2
              ? ''
              : a.isReceive == 0
                ? '待确认'
                : a.isReceive == 1
                  ? '待配送'
                  : a.isReceive == 2
                    ? '已过期'
                    : a.isReceive == 3
                      ? '已配送'
                      : ''
          );
          _arry.push(
            a.giftType == 2
              ? ''
              : a.deliveryType == 1
                ? '专卖店配送'
                : a.deliveryType == 2
                  ? '五粮液总部配送'
                  : ''
          );
          _arry.push(
            a.giftType == 2 ? '' : a.isDeliver == 1 ? '已发货' : '未发货'
          );
          _arry.push(a.zqName == null ? '' : a.zqName.toString());
          _arry.push(a.baseName == null ? '' : a.baseName.toString());
          return _arry;
        })
        .forEach((a) => {
          arry.push(a);
        });
      var sheet = XLSX.utils.aoa_to_sheet(arry);
      //循环单元格设置样式
      var s = sheet['!ref'];
      sheet['A2'].s = {
        font: {
          name: '宋体',
          sz: 18,
          color: { rgb: '#FFFF0000' },
          bold: true,
          italic: false,
          underline: false,
        },
        alignment: {
          horizontal: 'center',
          vertical: 'center',
        },
      };
      var rows = s.substr(s.length - 1, 1);
      var cloums = [
        'A',
        'B',
        'C',
        'D',
        'E',
        'F',
        'G',
        'H',
        'I',
        'J',
        'K',
        'L',
        'M',
        'N',
        'O',
        'P',
        'Q',
        'R',
        'S',
        'T',
        'U',
      ];
      for (var j = 0; j < cloums.length; j++) {
        for (var i = 1; i <= rows; i++) {
          if (i == 1) {
            sheet[cloums[j] + i].s = {
              //样式
              font: {
                bold: true,
                italic: false,
                underline: false,
              },
              alignment: {
                horizontal: 'left',
                vertical: 'left',
                wrap_text: false,
              },
            };
          } else {
            sheet[cloums[j] + i].s = {
              //样式
              alignment: {
                horizontal: 'left',
                vertical: 'left',
                wrap_text: false,
              },
            };
          }
        }
      }
      sheet['!cols'] = [
        {
          wpx: 90,
        },
        {
          wpx: 90,
        },
        {
          wpx: 90,
        },
        {
          wpx: 90,
        },
        {
          wpx: 150,
        },
        {
          wpx: 150,
        },
        {
          wpx: 150,
        },
        {
          wpx: 180,
        },
        {
          wpx: 150,
        },
        {
          wpx: 150,
        },
        {
          wpx: 150,
        },
        {
          wpx: 180,
        },
        {
          wpx: 320,
        },
        {
          wpx: 150,
        },
        {
          wpx: 120,
        },
        {
          wpx: 480,
        },
        {
          wpx: 120,
        },
        {
          wpx: 120,
        },
        {
          wpx: 480,
        },
        {
          wpx: 120,
        },
        {
          wpx: 120,
        },
        {
          wpx: 120,
        },
        {
          wpx: 120,
        },
        {
          wpx: 120,
        },
        {
          wpx: 120,
        },
      ]; //单元格列宽
      this.openDownloadDialog(
        this.sheet2blob(sheet),
        new Date().toLocaleDateString() + '会员中奖记录表.xlsx'
      );

      // /* generate workbook object from table */
      // let wb = XLSX.utils.table_to_book(document.querySelector('#rebateSetTable'));
      // /* get binary string as output */
      // let wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
      // try {
      //     FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), '会员中奖记录表.xlsx');
      // } catch (e)
      // {
      //     if (typeof console !== 'undefined')
      //         console.log(e, wbout)
      // }
      // return wbout
    },
    sheet2blob(sheet, sheetName) {
      sheetName = sheetName || 'sheet1';
      var workbook = {
        SheetNames: [sheetName],
        Sheets: {},
      };
      workbook.Sheets[sheetName] = sheet;
      // 生成excel的配置项
      var wopts = {
        bookType: 'xlsx', // 要生成的文件类型
        bookSST: false, // 是否生成Shared String Table，官方解释是，如果开启生成速度会下降，但在低版本IOS设备上有更好的兼容性
        type: 'binary',
      };
      var wbout = XLSX.write(workbook, wopts);
      var blob = new Blob([s2ab(wbout)], { type: 'application/octet-stream' });
      // 字符串转ArrayBuffer
      function s2ab(s) {
        var buf = new ArrayBuffer(s.length);
        var view = new Uint8Array(buf);
        for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xff;
        return buf;
      }
      return blob;
    },

    openDownloadDialog(url, saveName) {
      if (typeof url == 'object' && url instanceof Blob) {
        url = URL.createObjectURL(url); // 创建blob地址
      }
      var aLink = document.createElement('a');
      aLink.href = url;
      aLink.download = saveName || ''; // HTML5新增的属性，指定保存文件名，可以不要后缀，注意，file:///模式下不会生效
      var event;
      if (window.MouseEvent) event = new MouseEvent('click');
      else {
        event = document.createEvent('MouseEvents');
        event.initMouseEvent(
          'click',
          true,
          false,
          window,
          0,
          0,
          0,
          0,
          0,
          false,
          false,
          false,
          false,
          0,
          null
        );
      }
      aLink.dispatchEvent(event);
    },
    //显示配置弹窗
    showConfigTableDialog() {
      this.configTableDialogVisible = true;
    },
    //关闭配置弹窗
    closeConfigTableDialog() {
      this.queryUserMenuFieldByParam();
      this.configTableDialogVisible = false;
    },
    //获取列表字段列表
    queryUserMenuFieldByParam() {
      let data = {
        menuCode: this.formInline2.menuCode,
      };
      this.userMenuAllFields = []; //全部的列名
      this.userMenuShowFields = []; //显示的列名
      queryUserMenuFieldByParam(data).then((res) => {
        this.userMenuFieldList = res.records;
        this.userMenuFieldList.forEach((item, index) => {
          this.userMenuAllFields.push(item.fieldCode);
          if (item.isShow == 1) {
            this.userMenuShowFields.push(item.fieldCode);
          }
        });
        if (
          this.userMenuShowFields.length == 0 ||
          this.userMenuShowFields.length == this.userMenuAllFields.length
        ) {
          this.userMenuShowFields = this.userMenuAllFields;
          this.formInline2.isAll = true;
        } else {
          this.formInline2.isAll = false;
          this.formInline2.isIndeterminate = true;
        }
      });
    },
    //保存显示字段
    insertUserFieldRelation() {
      if (
        this.userMenuShowFields == null ||
        this.userMenuShowFields.length == 0
      ) {
        this.$message({
          showClose: true,
          message: '列表字段不可为空',
          type: 'info',
        });
        return;
      }
      let data = {
        menuCode: this.formInline2.menuCode,
        fieldList: this.userMenuShowFields,
      };
      this.insertLoading = true;
      insertUserFieldRelation(data).then((res) => {
        this.insertLoading = false;
        if (res.code == 1) {
          this.$message({
            showClose: true,
            message: res.message,
            type: 'success',
          });
          this.closeConfigTableDialog();
        } else {
          this.$message({
            showClose: true,
            message: res.message,
            type: 'error',
          });
        }
      });
    },
    //是否全选字段
    isAllFieldChange(val) {
      this.userMenuShowFields = val ? this.userMenuAllFields : [];
      this.formInline2.isIndeterminate = false;
    },
    //是否选中单个字段
    isSingleFieldChange(val) {
      let checkedCount = this.userMenuShowFields.length;
      this.formInline2.isAll = checkedCount === this.userMenuAllFields.length;
      this.formInline2.isIndeterminate =
        checkedCount > 0 && checkedCount < this.userMenuAllFields.length;
    },
    //获取字段勾选状态
    getUserMenuFieldStatus(fieldCode) {
      if (this.userMenuShowFields != null) {
        for (let i = 0; i < this.userMenuShowFields.length; i++) {
          if (this.userMenuShowFields[i] == fieldCode) {
            return true;
          }
        }
        return false;
      }
    },
    //是否显示字段
    isShow(fieldCode) {
      if (this.formInline2.isAll || this.getUserMenuFieldStatus(fieldCode)) {
        return true;
      } else {
        return false;
      }
    },
    _getAllZone() {
      let data = {};
      getAllZone(data).then((res) => {
        this.corpList = res.result;
      });
    },
    selCore(value) {
      if (value != '' && value != undefined && value != null) {
        this.orgSeq = value;
        let data = { code: value };
        getAllBase(data).then((res) => {
          this.RentalPayWay = res.result;
          this.formInline.baseOrgSeq = '';
        });
      } else if (this.formInline.baseOrgSeq != '') {
        this.orgSeq = this.formInline.baseOrgSeq;
      } else {
        this.orgSeq = JSON.parse(this.logininfo).orgSeq;
      }
    },
    selbase(value) {
      if (value != '' && value != undefined && value != null) {
        this.orgSeq = value;
      } else if (this.formInline.zqOrgSeq != '') {
        this.orgSeq = this.formInline.zqOrgSeq;
      } else {
        this.orgSeq = JSON.parse(this.logininfo).orgSeq;
      }
    },
    //流导出
    exportExcel1() {
      let data = {
        size: this.total,
        current: 1,
        condition: {
          keyword: this.formInline.keyword.trim(),
          keyWords: this.formInline.keyWords.trim(),
          activityName: this.formInline.activityName.trim(),
          authCode: this.formInline.authCode.trim(),
          storeName: this.formInline.storeName.trim(),
          province: this.formInline.province.trim(),
          city: this.formInline.city.trim(),
          county: this.formInline.county.trim(),
          zqOrgSeq: this.formInline.zqOrgSeq,
          baseOrgSeq: this.formInline.baseOrgSeq,
          memberLevel: this.formInline.gradelevelId,
          prizeLevelName: this.formInline.prizeLevelId,
          status: this.formInline.status,
          memberPstype: this.formInline.memberPstype,
          isReceive: this.formInline.isReceive,
          deliveryType: this.formInline.deliveryType,
          isDeliver: this.formInline.isDeliver,
          giftType: this.formInline.giftType,
          beginDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 0
              ? this.formInline.dateRange[0]
              : '',
          endDate:
            this.formInline.dateRange !== undefined &&
              this.formInline.dateRange.length > 1
              ? this.formInline.dateRange[1]
              : '',
          fhBeginDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 0
              ? this.formInline.dateRangefh[0]
              : '',
          fhEndDate:
            this.formInline.dateRangefh !== undefined &&
              this.formInline.dateRangefh.length > 1
              ? this.formInline.dateRangefh[1]
              : '',
          psBeginDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 0
              ? this.formInline.dateRangeps[0]
              : '',
          psEndDate:
            this.formInline.dateRangeps !== undefined &&
              this.formInline.dateRangeps.length > 1
              ? this.formInline.dateRangeps[1]
              : '',
          orgSeq: this.formInline.orgSeq,
          getBeginDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 0
              ? this.formInline.dateRangeGet[0]
              : '',
          getEndDate:
            this.formInline.dateRangeGet !== undefined &&
              this.formInline.dateRangeGet.length > 1
              ? this.formInline.dateRangeGet[1]
              : '',
        },
      };
      if (this.$route.params.activityType == 3 || this.$route.params.activityType == 4) {
        data.condition.activityId = this.$route.params.activityId
      }

      this.exportLoading = true;
      queryWinningRecordListExcel(data).then((res) => {
        this.exportLoading = false;
        let blob = new Blob([res], { type: 'application/vnd.ms-excel' });
        const link = document.createElement('a');
        link.style = 'display:none';
        link.href = URL.createObjectURL(blob);
        link.download = new Date().toLocaleDateString() + '会员中奖记录表.xlsx';
        document.body.appendChild(link);
        link.click();
      });
    },
    changeDeliveryType(value) {
      if (value == '2') this.formInline.memberPstype = '';
    },
  },
};
</script>
<style lang="less" scoped>
.el-form-item .el-select {
  width: 100%;
}

#configTableDiv .el-divider--horizontal {
  margin-top: 0;
}
</style>
